package com.sugon.entity.dto;

import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 模具维修工单导出参数
 *
 * @Author YuXD
 * @Version 1.0
 * @since 2023/12/27
 */
@Data
public class MoldRepairTicketExportParam implements Serializable {

    private String id;

    /**
     * 报修编号
     */
    private String repairCode;

    /**
     * 报修人
     */
    private String report;

    /**
     * 模具号
     */
    private String moduleNo;

    /**
     * 故障代码
     */
    private String faultCode;

    /**
     * 故障描述
     */
    private String faultDesc;

    /**
     * 报修时间
     */
    private Date repairDate;

    /**
     * 开始维修时间
     */
    private Date orderExecuteDate;

    /**
     * 结束维修时间
     */
    private Date orderEndDate;

    /**
     * 恢复时间
     */
    private Date resumeProductionTime;

    /**
     * 维修时间
     */
    private String repairDuration;

    public String getRepairDuration() {
        return (this.orderExecuteDate != null && this.orderEndDate != null) ? DateUtil.between(this.orderExecuteDate, this.orderEndDate, DateUnit.MINUTE) + 1 + "" : "";
    }

    /**
     * 停机时间
     */
    private String haltDuration;

    public String getHaltDuration() {
        return (this.repairDate != null && this.resumeProductionTime != null) ? DateUtil.between(this.repairDate, this.resumeProductionTime, DateUnit.MINUTE) + 1 + "" : "";
    }

    /**
     * 故障描述
     */
    private String recordDescr;

    /**
     * 解决方案
     */
    private String solution;

    /**
     * 备注
     */
    private String remark;

    /**
     * 设备名称
     */
    private String devName;

    /**
     * 维修人员
     */
    private String orderExecuteUsername;

    /**
     * 换件记录
     */
    private List<MoldRepairReplacementRecord> consumeList;

}
